package com.lengxf.pay.icbc.config;


import cn.hutool.core.util.StrUtil;
import cn.hutool.http.Method;
import com.lengxf.pay.common.config.ServerAddr;
import com.lengxf.pay.common.config.TransactionType;
import com.lengxf.pay.common.enums.PayChannel;
import com.lengxf.pay.common.http.UriModel;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum ICBC_TransactionType implements TransactionType {


    /**
     * 二维码生成
     */
    QR(UriModel.modelPost("/api/qrcode/V2/generate")),

    /**
     * 二维码查询
     */
    QUERY(UriModel.modelPost("/api/mybank/pay/qrcode/scanned/paystatus/V2")),

    /**
     * 退款
     */
    REFUND(UriModel.modelPost("/api/mybank/pay/qrcode/scanned/return/V2")),

    /**
     * 二维码退款查询
     */
    REFUND_QUERY(UriModel.modelPost("/api/mybank/pay/qrcode/scanned/returnstatus/V2")),
    ;


    private final UriModel uriModel;


    @Override
    public Method method() {
        return this.uriModel.getMethod();
    }

    @Override
    public String serverAddr() {
        String addr = ServerAddr.getAddr(PayChannel.ICBC);
        return StrUtil.isBlank(addr) ? "https://gw.open.icbc.com.cn" : addr;
    }

    @Override
    public String uri() {
        return this.uriModel.getUri();
    }

}
